﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ForzaGT3.Data;
using ForzaGT3.Helpers;
using ForzaGT3.Models;
using Google.GData.Client;
using Google.YouTube;

namespace ForzaGT3.Controllers
{
    public partial class HomeController : Controller
    {
        public virtual ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public virtual ActionResult About()
        {
            Data.Content content = Data.Content.GetByUrl("About");
            return View(content);
        }

        public virtual ActionResult LatestNews()
        {
            IEnumerable<News> data = News.GetAll()
                .OrderByDescending(x=>x.CreatedDate)
                .Take(3);

            ViewData.Model = data;

            return PartialView(MVC.Home.Views._LatestNews);
        }

        public virtual ActionResult HeadlineSlider()
        {
            IEnumerable<Feature> data = Feature.GetAll()
                .OrderByDescending(x => x.CreatedDate)
                .Take(4);

            ViewData.Model = data;

            return PartialView(MVC.Home.Views._HeadlineSlider);
        }

        public virtual ActionResult LatestVideos()
        {
            //List<YoutubeVideoModel> data = YoutubeVideoHelper.GetVideos();
            //ViewData.Model = data.Take(3);

            IEnumerable<Video> feeds = YoutubeVideoHelper.GetVideoFeed();
            ViewData.Model = feeds.Take(3);

            return PartialView(MVC.Home.Views._LatestVideos);
        }
    }
}
